汇编问题
请问下,汇编里面的代码是不能这样写的么:mov es:[15 - bx],dl(上面都已经定义了,就这里是报错的)
如果能这样写,那正确的格式是什么?
如果不能这样写,那么如何逆序的拷贝一个内存到另一个内存的?
谢谢了。
assume cs:code code segment mov ax,0ffffh mov ds,ax ;uint8_t *ds_seg = (uint8_t *)-1; mov ax,0020h mov es,ax ;uint8_t *es_seg = (uint8_t *)0x0020; mov bx,0 ;uint16_t i = 0; mov bp,14 ;uint16_t j = 14; mov cx,8 ;uint16_t count = 8; s1: mov al,[bx] mov es:[bp],al ;es_seg[j] = ds_seg[i]; add bx,2 ;i += sizeof(uint16_t); sub bp,2 ;j -= sizeof(uint16_t); loop s1 ;while (count > 0); mov bx,1 ;i = (uint16_t)1; mov bp,15 ;j = (uint16_t)15; mov cx,8 ;count = 8; s2: mov al,[bx] mov es:[bp],al ;es_seg[j] = ds_seg[i]; add bx,2 ;i += sizeof(uint16_t); sub bp,2 ;j -= sizeof(uint16_t); loop s2 ;while (count > 0); mov ax,4c00h int 21h ;exit(0); code ends end改后的代码
assume cs:code code segment mov ax,0ffffh mov ds,ax ;uint16_t *ds_seg = (uint16_t *)-1; mov ax,0020h mov es,ax ;uint16_t *es_seg = (uint16_t *)0x0020; mov bx,0 ;uint16_t i = 0; mov bp,0eh ;uint16_t j = 14; mov cx,8 ;uint16_t count = 8; s1: mov ax,[bx] mov es:[bp],ax ;es_seg[j] = ds_seg[i]; add bx,2 ;i += sizeof(uint16_t); sub bp,2 ;j -= sizeof(uint16_t); loop s1 ;while (count > 0); mov ax,4c00h int 21h ;exit(0); code ends end