[os] 打印字符串
来源:互联网 发布:最新的mac版本是多少 编辑:程序博客网 时间:2024/04/29 23:07
第一个例子原理很简单,但若没有一定的汇编实践经验,还是很容易在各种各样的细节上栽跟头的。
下面是我完成任务后的一些总结:
1. 我学习汇编的教材是基于dos的, 里面既介绍了bios中断,又介绍了dos中断,我没有注意两者的区别,直接调用了一个dos中断,结果搞了半天愣是没有结果。
所以使用中断时要注意区分两者, linux下不支持dos。
2. 写显存和调用int 10h(bios中断) 可以达到一样的效果。
3. 如果有一个字符串需要打印, 例如: PrintMsg: db "hello world";
此时若用ds:si 指向该字符串首地址,ds=PrintMsg, di=0 无法正确读取字符串。
可以让ds=cs, si=PrintMsg。 具体原因我现在也说不太清楚。
具体代码如下:
hello.asm(需要了解一下bios 10h中断):
----------------------------------------------------
org 07c00h
mov ax, cs
mov es, ax
mov bx, 000ch ; char attribute
mov cx, 13 ; the string length
mov dh, 1
mov dl, 1 ; row and column
mov bp, ScreenMsg ; the adress of string
mov ax, 1301h ; show the string
int 10h
jmp $
ScreenMsg: db "hello wupeng!"
times 510-($-$$) db 0
dw 0xaa55
-----------------------------------------------------
boot.sh:
-----------------------------------------------------
#!/bin/bash
nasm hello.asm -o hello.bin
dd if=hello.bin of=a.img bs=512 count=1 conv=notrunc
-----------------------------------------------------
- [os] 打印字符串
- 打印字符串
- symbian os:字符串处理
- Linux打印不同颜色字符串
- DbgPrint打印字符串
- 字符串打印自动换行
- 字符串单个打印
- 99. 打印字符串
- 打印字符串所有字串
- 字符串拷贝,连接,打印
- 1709: 打印字符 (字符串)
- 指定打印的字符串
- python 打印unicode字符串
- 打印字符串反转
- python打印文档字符串
- gdb打印字符串
- 递归逆序打印字符串
- swift 打印字符串 Optional
- 35岁以前成功的12条黄金法则(1)
- 代码规范
- LINUX各种压缩
- BlazeDS Tutorial – Remote Object Service
- (转)追MM与设计模式(java的32种设计模式)
- [os] 打印字符串
- Linux下发送自定义信号 C++代码
- XSS攻击防御
- table 转换成div的代码
- 关于css的界面问题:
- Comet:基于 HTTP 长连接的“服务器推”技术
- 英国的儿童宣言(未经考证),建议有子女的朋友看看
- jQuery技巧
- x-y/球面坐标